<?php
/**
 * @author 天涯 <mail@phpha.com>
 * @copyright http://blog.phpha.com
 * @link http://blog.phpha.com/vncms
 * @version 1.0
 */
defined('APP_PATH') or exit('Access Denied');
require 'check.php';
class zpin extends check{
	//招聘列表
	public function lis(){
		$page = (int) $this->spArgs('page',1) > 1 ? (int) $this->spArgs('page',1) : 1;
		$this->zpin = spClass('m_zpin')->spPager($page,15)->findAll(null,'id DESC');
		$this->pager = spClass('m_zpin')->spPager()->getPager();
		$this->display('zpin_lis.tpl.php');
	}
	//添加招聘
	public function add(){
		$this->display('zpin_add.tpl.php');
	}
	public function doadd(){
		if(false != spClass('m_zpin')->spVerifier($this->spArgs()))	$this->error('数据验证错误！',spUrl('zpin','add'));
		$rows = $this->spArgs();
		$rows['stime'] = strtotime($rows['stime']);
		$rows['etime'] = strtotime($rows['etime']);
		if(false != spClass('m_zpin')->create($rows)){
			$this->success('添加招聘信息成功！',spUrl('zpin','lis'));
		}else{
			$this->error('添加招聘信息失败！',spUrl('zpin','add'));
		}
	}
	//更新招聘
	public function upd(){
		if(!$id = intval($this->spArgs('id')))	$this->error('缺少必要参数！',spUrl('zpin','lis'));
		$this->zpin = spClass('m_zpin')->find(array('id'=>$id));
		$this->display('zpin_upd.tpl.php');
	}
	public function doupd(){
		if(!$id = intval($this->spArgs('id')))	$this->error('缺少必要参数！',spUrl('zpin','lis'));
		$rows = $this->spArgs();
		$rows['stime'] = strtotime($rows['stime']);
		$rows['etime'] = strtotime($rows['etime']);
		if(false != spClass('m_zpin')->update(array('id'=>$id),$rows)){
			$this->success('更新招聘信息成功！',spUrl('zpin','lis'));
		}else{
			$this->error('更新招聘信息失败！',spUrl('zpin','lis'));
		}
	}
	//删除招聘
	public function del(){
		if(!$id = intval($this->spArgs('id')))	$this->error('缺少必要参数！',spUrl('zpin','lis'));
		if(false != spClass('m_zpin')->delete(array('id'=>$id))){
			$this->success('删除招聘信息成功！',spUrl('zpin','lis'));
		}else{
			$this->error('删除招聘信息失败！',spUrl('zpin','lis'));
		}
	}
	//批量删除
	public function pldel(){
		if(!$idrow = $this->spArgs('id'))	$this->error('请选择要删除的编号！',spUrl('zpin','lis'));
		for($i=0;$i<count($idrow);$i++){
			spClass('m_zpin')->delete(array('id'=>$idrow[$i]));
		}
		$this->success('批量删除招聘信息成功！',spUrl('zpin','lis'));
	}
}
